/*
Copyright (C) 2013 Matthew Netsch

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#pragma once

#define PASSMAN_VERSION 1

#ifdef PASSMAN_EXPORT
#define PASSMAN_API __declspec(dllexport)
#else
#define PASSMAN_API __declspec(dllimport)
#endif

namespace PassMan
{
    class IPass
    {
    public:
        virtual ~IPass() = 0;

        virtual void setValue(const char *value)     = 0;
        virtual bool getName(char *name, int size)   = 0;
        virtual bool getValue(char *name, int size)  = 0;
        virtual int  getNameSize()                   = 0;
        virtual int  getValueSize()                  = 0;
    };

    /**
    *	Database interface provides a way to CRUD the passwords that it stores
    */
    class IDatabase
    {
    public:

        //Interface for recieving notifications that database changed
        class IObserver
        {
        public:
            virtual void notify() = 0;
        };

        virtual ~IDatabase() = 0;

        virtual IPass* Create(const char *name)    = 0;
        virtual IPass* Retrieve(const char *name)  = 0;
        virtual IPass* Retrieve(int index)         = 0;
        virtual void   Update(IPass *pass)         = 0;
        virtual void   Destroy(IPass *pass)        = 0;

        virtual void   setName(const char *name)   = 0;
        virtual void   setKey(const char *key)     = 0;
        virtual int    getNumPass()                = 0;

        virtual IDatabase* clone()                 = 0;

        virtual void   registerObserver(IObserver *observer) = 0;
    };

    /**
    *	DatabaseManager interface provides a way to CRUD password databases
    */
    class IDatabaseManager
    {
    public:
        typedef enum
        {
            DATABASE_FILE = 0	///< Stores databases in local files
        } DatabaseManagerType;

        static PASSMAN_API IDatabaseManager* Create(DatabaseManagerType type);

        virtual ~IDatabaseManager() = 0;

        virtual IDatabase*  Create(const char *name, const char *key)        = 0;
        virtual IDatabase*  Retrieve(const char *name, const char *key)      = 0;
        virtual void        Update(IDatabase *database)                      = 0;
        virtual void        Destroy(IDatabase *database)                     = 0;
    };

}
